﻿using BarrageGrab.Entity.Models.Douyin;
using BarrageGrab.GrabServices;
using BarrageGrab.Websocket;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BarrageGrab
{
    /// <summary>
    /// 服务注册器
    /// </summary>
    internal static class ServiceRegistrar
    {
        internal static void BuildServices()
        {
            ////创建数据库对象 (用法和EF Dappper一样通过new保证线程安全)
            //SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
            //{
            //    ConnectionString = "datasource=dm.db",
            //    DbType = DbType.Sqlite,
            //    IsAutoCloseConnection = true
            //}, db => {

            //    db.Aop.OnLogExecuting = (sql, pars) =>
            //    {

            //        //获取原生SQL推荐 5.1.4.63  性能OK
            //        Console.WriteLine(UtilMethods.GetNativeSql(sql, pars));

            //        //获取无参数化SQL 对性能有影响，特别大的SQL参数多的，调试使用
            //        //Console.WriteLine(UtilMethods.GetSqlString(DbType.SqlServer,sql,pars))


            //    };
            //});


          
            //本机websocket服务
            ApplicationRuntime.LocalWebSocketServer = new LocalWebSocketServer();
            ApplicationRuntime.LocalWebSocketServer.Start();

            //抖音弹幕抓取服务
            ApplicationRuntime.BarrageGrabService = new DouyinBarrageGrabService();
            //ApplicationRuntime.BarrageGrabService.Run(""); //其他地方调用



        }

    }
}
